package com.example.mybatisplus.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.mapper.HOrderMapper;
import com.example.mybatisplus.mapper.HouseDetailMapper;
import com.example.mybatisplus.model.dto.DataDto;
import com.example.mybatisplus.model.dto.PageDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.HOrderService;
import com.example.mybatisplus.model.domain.HOrder;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


/**
 * 前端控制器
 *
 * @author yfy
 * @version v1.0
 * @since 2021-12-30
 */
@RestController
@RequestMapping("/api/hOrder")
@Slf4j
public class HOrderController {

    private final Logger logger = LoggerFactory.getLogger(HOrderController.class);

    @Autowired
    private HOrderService hOrderService;
    @Autowired
    private HOrderMapper orderMapper;
    @Autowired
    private HouseDetailMapper houseDetailMapper;

    @GetMapping("/list")
    public JsonResponse list(PageDto page, HOrder order) {
        Page<HOrder> list = hOrderService.listByPage(page, order);
        return JsonResponse.success(list);
    }

    @GetMapping("/backById")
    public JsonResponse deleteById(Long id) {
        orderMapper.updateBack(id);
        return JsonResponse.success(true);
    }
    @GetMapping("/checkById")
    public JsonResponse checkById(Long id) {
        orderMapper.updateBack1(id);
        return JsonResponse.success(true);
    }

    @GetMapping("selectById")
    public JsonResponse selectById(Long id) {
        List<HOrder> orders = orderMapper.selectByIds(3001L);
        return JsonResponse.success(orders);
    }

    @GetMapping("/orderNow")
    public JsonResponse orderNow(DataDto dataDto) {
//        System.out.println(dataDto.getTime1());
//        System.out.println(dataDto.getTime2());
//        System.out.println();
        return JsonResponse.success(true);
    }
}

